package com.fas.core.web.response;

import net.sf.json.JSONObject;
/**
 * Cottroler JSON格式返回客户端结果
 *
 * @Copyright: Copyright (c) 2016 FAS 
 * @anthor yixiaoping<thinker1013@163.com>
 * @since 2016年1月23日 下午10:48:59
 * @version V1.0
 */
@SuppressWarnings("serial")
public class JSONResult<T> extends Result{
	
	protected T data;

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
	
	public JSONResult() {
	}
	
	public JSONResult(ResultStatus status) {
		super(status);
	}
	
	public JSONResult(ResultStatus status, String message) {
		super(status, message);
	}
	
	public JSONResult(ResultStatus status, String message, T data) {
		super(status, message);
		this.data = data;
	}

	public String getJsonString(){
		JSONObject jsonObject =  new JSONObject();
		jsonObject.put("status", this.getStatus());
		jsonObject.put("message", this.getMessage());
		jsonObject.put("data", this.getData());
		return jsonObject.toString();
	}
	
}
